<extend name="Public/base" />

<block name="style">
	<link rel="stylesheet" type="text/css" href="__STATIC__/plugins/bootstrap-fileupload/bootstrap-fileupload.css" />
</block>
<!-- 子导航 -->
<block name="sidebar">
    <include file="sidemenu" />
</block>

<block name="body">

	<div class="row">
        <div class="col-md-12">
        
            <div class="note note-warning">
                <h4 class="block"> 批量导入</h4>
                <p> [
                    <volist name="rightNav" id="nav">
                    <a href="{:U('article/index','cate_id='.$nav['id'])}">{$nav.title}</a>
                    <if condition="count($rightNav) gt $i"><i class="ca"></i></if>
                    </volist>
                    <present name="article">：<a href="{:U('article/index','cate_id='.$info['category_id'].'&pid='.$article['id'])}">{$article.title}</a></present>
                    ]
                </p>
            </div>
            
            <div class="tabbable tabbable-custom boxless">
                <form id="form" action="{:U('batchoperate')}" method="post" class="form-1" >
                <script> var _file = []; _file['picture'] = [];_file['file'] = [];</script>
                
                <div class="tab-content">
                    <div class="portlet box blue">
                        <div class="portlet-title">
                            <div class="caption"><i class="fa fa-reorder"></i>批量导入</div>
                            <div class="tools">
                                <a href="javascript:;" class="collapse"></a>
                                <a href="#portlet-config" data-toggle="modal" class="config"></a>
                                <a href="javascript:;" class="reload"></a>
                                <a href="javascript:;" class="remove"></a>
                            </div>
                        </div>
                        <div class="portlet-body form">
                            <!-- BEGIN FORM-->
                            
                                <div class="form-body">
                                
                                    <div class="form-group">
                                        <label>文档模型<span class="check-tips">（选择要导入的文档模型）</span></label>
                                        <select name="model_id" class="form-control input-medium" >
                                            <volist name=":explode(',',get_category($cate_id, 'model'))" id="vo">
                                                <option value="{$vo.id}">{:get_document_model($vo['title'],'title')}</option>
                                            </volist>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label>文档类型<span class="check-tips">（选择要导入的文档类型，目前仅支持目录）</span></label>
                                        <select name="type" class="form-control input-medium" >
                                            <option value="1">目录</option>
                                        </select>
                                    </div>
                                    
                                    <div class="form-group">
                                        <label>导入的内容<span class="check-tips">（请按照导入格式输入，第一列为产品名称，第二列为cas号，第三列为其他常用名，第四列为详情）</span></label>
										<script> _file['file'].push("content")</script>
                                        <div class="fileupload fileupload-new" data-provides="fileupload">
                                            <div class="input-group">
                                                <span class="input-group-btn">
                                                    <span class="uneditable-input">
                                                        <i class="fa fa-file fileupload-exists"></i> 
                                                        <span class="fileupload-preview"></span>
                                                    </span>
                                                </span>
                                                <span class="btn-file">
                                                    <input type="file" class="default"  id="content" />
													<input type="hidden" name="content"/>
                                                </span>
                                                <a href="#" class="btn red fileupload-exists" data-dismiss="fileupload"><i class="fa fa-trash-o"></i> 删除</a>
                                            </div>
                                        </div>
                                    </div>
                                    
                                </div>
                                
                                
                                <div class="form-actions fluid ">
                                    <div class="col-md-offset-3 col-md-9">
                                        <button class="btn green submit-btn ajax-post" id="submit" type="submit" target-form="form-1">确 定</button>
                                        <a class="btn default btn-return" href="{:U('article/index?cate_id='.$cate_id)}">返 回</a>
                                        <input type="hidden" name="pid" value="{$pid}"/>
                                        <input type="hidden" name="cate_id" value="{$cate_id}">                   
                                    </div>
                                </div>
                            
                            <!-- END FORM--> 
                        </div>
                    </div>
                </div>
                
                </form>
            </div>
        </div>
    </div>
    
</block>

<block name="script">
	<!-- BEGIN PAGE LEVEL SCRIPTS -->
	<script src="__STATIC__/scripts/app.js"></script>
	<script src="__STATIC__/scripts/form-components.js"></script> 
	<script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js?t={:rand(0,9999)}"></script>
	<script type="text/javascript" src="__STATIC__/plugins/bootstrap-fileupload/bootstrap-fileupload.js"></script>
	<!-- END PAGE LEVEL SCRIPTS -->
	<script>
	jQuery(document).ready(function() {       
		// initiate layout and plugins
		App.init();
		
		_file['file'].forEach(function(i){
			$("#"+i).uploadify({
				"height"          : 34,
				"swf"             : "__STATIC__/uploadify/uploadify.swf",
				"fileObjName"     : "download",
				"buttonText"      : "上传附件",
				"uploader"        : "{:U('File/upload',array('session_id'=>session_id()))}",
				"width"           : 120,
				'removeTimeout'	  : 1,
				"onUploadSuccess" : function(file, data){
					var data = $.parseJSON(data);
					
					if(data.status){
						var name = i;
						$("input[name="+name+"]").val(data.data);
						$('.uneditable-input').find('.fileupload-preview').html(data.info);
						$('.uneditable-input').find('i').removeClass('fileupload-exists');
					} else {
						updateAlert(data.info);
						setTimeout(function(){
							$('#top-alert').find('button').click();
						},1500);
					}
				},
				'onFallback' : function() {
					alert('未检测到兼容版本的Flash.');
				}
			});
		})
		
	});
	</script>
</block>
